package com.sl.au.repository;
/**
 * 合同回款历史DAO层1
 * zty
 * 2017-02-20
 */
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.ContractBillInfo;
import com.sl.au.entity.EXDELoginInfo;
import com.sl.au.entity.EXDEpayHistoryInfo;
import com.sl.au.entity.WholeSetPrice;
@Transactional(readOnly = true)
public interface EXDEpayHistoyRepository extends JpaRepository<EXDEpayHistoryInfo, String>{
	//根据key得数据,
	@Query("select n from EXDEpayHistoryInfo n where n.cSuperior = ?1")
	Page<EXDEpayHistoryInfo> getexdepayHistoryInfo(String superior,Pageable pageable);
	//根据key得数据条数
	@Query("select count(k) from EXDEpayHistoryInfo k where k.cSuperior = ?1")
	long getCount(String superior);
	//查询的SQL语句
	@Query("select i from EXDEpayHistoryInfo i where i.cSuperior = ?1 and (i.cCustomerName like '%'+?2+'%'"
	          +"or i.cprojectName like '%'+?2+'%' or i.careaName like '%'+?2+'%'" 
	          +"or i.csPayMan like '%'+?2+'%' or i.csPaidWay like '%'+?2+'%' "
	          +"or i.csMemo like '%'+?2+'%')")
	Page<EXDEpayHistoryInfo> getexdepayHistoryInfo(String superior,String key,Pageable pageable);//注意传值顺序
	//查询获得的条数
	@Query("select count(i) from EXDEpayHistoryInfo i where i.cSuperior = ?1 and (i.cCustomerName like '%'+?2+'%'"
	          +"or i.cprojectName like '%'+?2+'%' or i.careaName like '%'+?2+'%'" 
	          +"or i.csPayMan like '%'+?2+'%' or i.csPaidWay like '%'+?2+'%' "
	          +"or i.csMemo like '%'+?2+'%')")
	long getCount(String superior,String key);//注意顺序
}
